<?php
class ModelNewsNews extends Model {
    
	public function getAllarticle($page, $limit) {
	   $sql = "SELECT  * FROM " . DB_PREFIX . "content c LEFT JOIN " . DB_PREFIX . "content_description cd ON (c.content_id = cd.content_id)";
       
       
       $sql .= ' ORDER BY  c.date_modified DESC';
       if($limit){
            $page = ($page - 1) * $limit;
            $sql .= " LIMIT $page,$limit";
       }
    		$query = $this->db->query($sql);	
		return $query->rows;
	}
	
    public function getArticleById($content_id) {
	   $query = $this->db->query("SELECT  * FROM " . DB_PREFIX . "content c LEFT JOIN " . DB_PREFIX . "content_description cd ON (c.content_id = cd.content_id) WHERE c.content_id = '" . (int)$content_id . "'");	
		return $query->row;
	}
    
    public function getTotalArticles() {
	   $query = $this->db->query("SELECT  COUNT(*) as total FROM " . DB_PREFIX . "content c ");	
		return $query->row['total'];
	}
	public function getAllarticleNewst() {
	   $sql = "SELECT  * FROM " . DB_PREFIX . "content c LEFT JOIN " . DB_PREFIX . "content_description cd ON (c.content_id = cd.content_id)";
       
       
       $sql .= ' ORDER BY  c.date_modified DESC LIMIT 0,2';
      
    		$query = $this->db->query($sql);	
		return $query->rows;
	}
}
?>